#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

int n, K, m, bel[N];
int p[N], tp[N], ct[N];
int ans[N], tans[N];

struct ele {
	int a, b, c;
	friend bool operator == (ele x, ele y) { return x.a == y.a && x.b == y.b && x.c == y.c; }
} t[N];

namespace T {
	int tr[N];
	void add(int x, int v) { for(; x <= K; x += x & -x) tr[x] += v; }
	int query(int x) { int ret = 0; for(; x; x -= x & -x) ret += tr[x]; return ret; }
}

void solve(int l, int r) {
	if(l == r) return; int mid = l + r >> 1;
	solve(l, mid), solve(mid + 1, r);
	int p1 = l, p2 = mid + 1;
	while(p1 <= mid && p2 <= r) {
		if(t[p[p1]].b <= t[p[p2]].b) T :: add(t[p[p1]].c, ct[p[p1]]), p1++;
		else tans[p[p2]] += T :: query(t[p[p2]].c), p2++;
	}
	while(p2 <= r) tans[p[p2]] += T :: query(t[p[p2]].c), p2++;
	p1--; while(p1 >= l) T :: add(t[p[p1]].c, -ct[p[p1]]), p1--;
	inplace_merge(p + l, p + mid + 1, p + r + 1, [&](int x, int y) {
		return t[x].b ^ t[y].b ? t[x].b < t[y].b : t[x].c ^ t[y].c ? t[x].c < t[y].c : t[x].a < t[y].a;
	});
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, K = in;
	rep(i, 1, n) t[i].a = in, t[i].b = in, t[i].c = in;
	iota(tp + 1, tp + n + 1, 1);
	sort(tp + 1, tp + n + 1, [&](int x, int y) {
		return t[x].a ^ t[y].a ? t[x].a < t[y].a : t[x].b ^ t[y].b ?
			t[x].b < t[y].b : t[x].c < t[y].c;
	});
	rep(i, 1, n) {
		if(i != 1 && t[tp[i]] == t[p[m]]) ct[p[m]]++;
		else p[++m] = tp[i], ct[p[m]]++;
		bel[tp[i]] = p[m];
	}
	solve(1, m);
	rep(i, 1, n) {
		ans[tans[bel[i]] + ct[bel[i]] - 1] += 1;
	} rep(i, 0, n - 1) printf("%d\n", ans[i]);
	return 0;
}
